package com.vincent.exam.tree;

/**
 * 操作给定的二叉树，将其变换为源二叉树的镜像。
 */
public class MirrorTree {
    public void Mirror(TreeNode root) {
        swap(root);
    }

    public void swap(TreeNode root){
        if(root == null){
            return;
        }
        TreeNode temp = root.left;
        root.left = root.right;
        root.right = temp;
        if(root.left!= null){
            swap(root.left);
        }
        if(root.right != null){
            swap(root.right);
        }
    }
}
